package TestSparkConversionOperator;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

public class SparkDistinct {
    /**
     * 去除重复的元素后，返回一个新的RDD。
     * @param args
     */
    public static void main(String[] args) {
        SparkConf sparkConf = new SparkConf().setAppName("Distinct").setMaster("local");

        JavaSparkContext sc = new JavaSparkContext(sparkConf);

        JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 1, 2, 2, 3, 3));

        JavaRDD<Integer> rdd1 = rdd.distinct();
        List<Integer> res = rdd1.collect();
        for (Integer i : res){
            System.out.println(i);
        }



    }
}
